import App from './App'

// #ifndef VUE3
import Vue from 'vue'
import uView from '@/uni_modules/uview-ui';
Vue.use(uView);

Vue.config.productionTip = false

Vue.prototype.go = function(url,id){
	uni.$u.route(url);
}






uni.$u.http.interceptors.response.use((response) => {
	return response
}, (response) => {
	/*  对响应错误做点什么*/
	if(response.data.code === 401){
		var ua = navigator.userAgent.toLowerCase();
		if (ua.match(/MicroMessenger/i) == "micromessenger") {
			location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx154dd8349a505277&redirect_uri=https%3A%2F%2Fsport.luojiweiye.com%2Fweb%2Fzhibodengluzhuanyong%2Findex.html%3Factivity_id%3D'+uni.getStorageSync('activity_id')+'&sign_id='+uni.getStorageSync('sign_id')+'&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect'
			
		}else{
			uni.$u.route({type:"redirectTo",url:'/pages/login/index'});
			//非微信环境登陆
			//return Promise.reject(response)
		}
	}else{
		return Promise.reject(response)
	}
})

if (process.env.NODE_ENV === "development") {
	Vue.prototype.urlass = '/apis'
}
if (process.env.NODE_ENV === "production") {
	Vue.prototype.urlass = ''
}

Vue.prototype.yibuget = function(url,canshu){
	return new Promise((r, j) => {
		uni.$u.http.get(this.urlass + url, {
			params: canshu
		}).then(res => {
			r(res)
		})
	})
}
Vue.prototype.yibupost = function(url,canshu){
	return new Promise((r, j) => {
		uni.$u.http.post(this.urlass + url, canshu).then(res => {
			r(res)
		})
	})
}

App.mpType = 'app'
const app = new Vue({
    ...App,
	beforeCreate(){
		Vue.prototype.$bus = this
	}
})
app.$mount()
// #endif

// #ifdef VUE3
import { createSSRApp } from 'vue'
export function createApp() {
  const app = createSSRApp(App)
  return {
    app
  }
}
// #endif